#define NOODIRECT
#include "../Buffer-Parallel/IBuffer.cpp"
#include "../Buffer-Parallel/OBuffer.cpp"
#include <UnitTest++.h>
#include <stdio.h>

SUITE(BufferParallelTests) {

	TEST(InputBuffer) {
		IBuffer ibuffer;
		char input[] = "./testinput.txt";
		bool result = ibuffer.init(input);
		for (int i = 0; i < 1500000; i++) {
			ibuffer.getChar();
		}

		int tmp = ibuffer.ungetChar(100000);
		if (tmp == -1) {
			puts("ungetchar failed: string too long");
		}else if (tmp == -2) {
			puts("ungetchar failed: beginning of file reached");
		}

		CHECK(result == true);
	}

	TEST(OutputBuffer) {
		OBuffer obuffer;
		char output[] = "./testoutput.txt";
		bool result = obuffer.init(output);
		char c2[] = "Test Test Test Test Test Test \n";
		for(int i = 0; i < 100000; i++){
			obuffer.writeString(c2);
		}
		CHECK(result == true);
	}

}
